function qs(ele) {
    return ele = document.querySelector(ele)
}
axios.defaults.baseURL = 'http://124.223.14.236:3001/api'
render()
async function render() {
    const { data: { data: res } } = await axios({
        method: 'GET',
        url: '/city/province',
    })
    // console.log(res)
    const prov = res.map(item => {
        return `
        <option value="${item.province}">${item.name}</option>
        `
    }).join('')
    qs('#province').innerHTML = `<option value="">请选择省份</option>` + prov

}
qs('#province').addEventListener('change',async function () {
    const { data: { data: res1 } } = await axios.get('/city/city', {
        params: {
            provinceCode: this.value,
        }
    })
    // console.log(res1)
    const city = res1.map(item => {
        return `
        <option value="${item.city}">${item.name}</option>
        `
    }).join('')
    qs('#city').innerHTML = `<option value="">请选择城市</option>` + city
    qs('#county').innerHTML = `<option value="">请选择区县</option>`
})
qs('#city').addEventListener('change',async function () {
    const { data: { data: res2 } } = await axios.get('/city/area', {
        params: {
            provinceCode: qs('#province').value,
            cityCode: this.value
        }
    })
    // console.log(res2)
    const count = res2.map(item => {
        return `
        <option value="${item.area}">${item.name}</option>
        `
    }).join('')
    qs('#county').innerHTML = `<option value="">请选择区县</option>` + count
})
